package com.zs.c3_ioc.config;

import com.zs.c3_ioc.dao.UserDao;
import com.zs.c3_ioc.dao.impl.UserDaoImpl;
import com.zs.c3_ioc.service.UserService;
import com.zs.c3_ioc.service.impl.UserServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ZhouShuang
 * @version 17
 * @Title
 * @date 2025/6/6 上午11:54
 */
@Configuration
public class SpringConfig {

    /**
     * 写在方法上面
     * 通常写在配置类中
     * 可以干预bean的实例化过程，jar包中的类如果配置bean就需要用到@Bean
     * @return
     */
    @Bean
    public UserService userService(){
        userDao();
        return new UserServiceImpl();
    }

    @Bean
    public UserDao userDao(){
        System.out.println("new UserDaoImpl()");
        return new UserDaoImpl();
    }
}
